/* 
** (Copyright) sejishikong <sejishikong@263.net>
** Authors:    sejishikong <sejishikong@263.net>
**             Wei Lian <lianwei2003.student@sina.com> 
** Maintainer: Wei Lian
**    This program is free software; you can redistribute it and/or modify
**    it under the terms of the GNU General Public License Version 2 as
**    published by the Free Software Foundation;
**
**    This program is distributed in the hope that it will be useful,
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**    GNU General Public License for more details.
**
**    You should have received a copy of the GNU General Public License
**    along with this program; if not, write to the Free Software
**    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**
*/

#ifndef SOPCAST_H
#define SOPCAST_H

#include <qapplication.h>
#include <qtabwidget.h>
#include <qvbox.h>
#include <qhbox.h>
#include <qlistview.h>
#include <qlabel.h>
#include <qslider.h>
#include <qpushbutton.h>
#include <qlineedit.h>
#include <qhttp.h>
#include <qbuffer.h>
#include <qregexp.h>
#include <qprocess.h>
#include <qstatusbar.h>
#include <qtimer.h>
#include <qsettings.h>
#include <qpalette.h>
#include <qsocketnotifier.h>
#include <qsocket.h>
#include <qmenubar.h>
#include <qradiobutton.h>

class MyPopupMenu;
class Sys;
class Config;
//////////class
class Sopcast:public QVBox
{
  Q_OBJECT			//// 
public:
  Sopcast (QWidget * parent = 0, const char *name = 0);
   ~Sopcast ();

protected:
//    virtual void mouseMoveEvent (QMouseEvent *);

private:
  char stateopen[64];
  int idbookmark;
  QStringList strlst;
  QListView *listchannel;	//*childlist;
  Sys *sys;
  QPopupMenu *history;
  MyPopupMenu *bookmark;
  QLabel *popup;
  Config *vboxconfig;
  QSocketNotifier *snstatus;
  QSocketNotifier *snrecord;
  QFile *recordfp;

  QBuffer *bufchannel;
  QProcess *sop;
  QProcess *player;
  QStatusBar *statuschannel;
  QStatusBar *statusbar;
  QHttp *http;
  QLineEdit *editsearch;
  void killsop ();
  void killplayer ();
  bool forkplayer ();
  bool forksop (QString);

  QString channelname;
  QPushButton *buttonchannel;
  QPushButton *buttonplayer;
  QPushButton *buttonrecord;
  QPushButton *buttonexpand;
  QPushButton *buttonsearch;

  void loadopenstate ();
  void saveopenstate ();
  void updateopenstate ();
  void loadbookmark ();
  void savebookmark ();

  bool fetchingchannel;
  char outport[8];
  QSlider *slidersound;
  bool flaghook;

  public slots:void fetchchannel ();

  private slots:		////
  void httpdone (bool);
  void onbuttonplayerclicked ();
  void onbuttonstopclicked ();
  void onbuttonquitclicked ();
  void onbuttonrecordclicked ();
  void onlistitemclicked (QListViewItem *);
  void onrightbuttonclicked (QListViewItem *, const QPoint &, int);
  void onmousemoved (QListViewItem *);
  void onsopexit ();
  void parsestdout ();
  void timerDone ();
  void onplayerexit ();
  void streamready (int);
  void recordstreamready (int);
  void onbuttonexpandclicked ();
  void onbuttonsearchclicked ();
  void onconfigclicked ();
  void onchoosehistory (int);
  void onchoosebookmark (int);
  void onbookmarkclicked ();
  void sound_write (int);
  void about ();
};

#endif
